package com.yeban.base.day03.homework;

import java.util.Scanner;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/9/27
 */
public class Test05 {

//    public static int fibonacci(int n) {
//        if(n == 1 || n == 2) {
//            return 1;
//        }
//
//        return fibonacci(n - 1) + fibonacci(n - 2);
//    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.print("请输入查看斐波那契数列的项数：");
        int n = sc.nextInt();

        int sum1 = 1;
        int sum2 = 1;
        int sum = 2;
        for(int i = 1; i <= n; i++) {
//            System.out.print(fibonacci(i) + " ");
            if(i == 1 | i == 2) {
                System.out.print(1 + " ");
            }

            if(i > 2) {
                sum = sum1 + sum2;
                System.out.print(sum + " ");
                sum1 = sum2;
                sum2 = sum;
            }
        }

    }
}
